//package com.eeds.datasources.aspect;
//
//import com.eeds.datasources.DataSourceNames;
//import com.eeds.datasources.DynamicDataSource;
//import com.eeds.datasources.annotation.DataSource;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Method;
//
///**
// * 多数据源，切面处理类
// * @author Flying
// * @email flying_miku@sina.com
// * @date 2017/9/16 22:20
// */
//@Aspect
//@Component
//@Slf4j
//public class DataSourceAspect {
//
//    @Pointcut("@annotation(com.eeds.datasources.annotation.DataSource)")
//    public void dataSourcePointCut() {
//
//    }
//
//    @Around("dataSourcePointCut()")
//    public Object around(ProceedingJoinPoint point) throws Throwable {
//        MethodSignature signature = (MethodSignature) point.getSignature();
//        Method method = signature.getMethod();
//
//        DataSource ds = method.getAnnotation(DataSource.class);
//        if(ds == null){
//            DynamicDataSource.setDataSource(DataSourceNames.MAIN_DATA_SOURCCE_NAME);
//            if(log.isDebugEnabled()) {
//                log.debug("set datasource is " + DataSourceNames.MAIN_DATA_SOURCCE_NAME);
//            }
//        }else {
//            DynamicDataSource.setDataSource(ds.name());
//            System.out.println(DynamicDataSource.getDataSource());
//            if(log.isDebugEnabled()) {
//                log.debug("set datasource is " + ds.name());
//            }
//        }
//
//        try {
//            return point.proceed();
//        } finally {
//            DynamicDataSource.clearDataSource();
//            log.debug("clean datasource");
//        }
//    }
//
//
//}
